import * as cc from "cc";
import { VMButtonClickEntity } from "./entities/VMButtonClickEntity";
import { VMChildEntity } from "./entities/VMChildEntity";
import { VMChildrenEntity } from "./entities/VMChildrenEntity";
import { VMComponentEntity } from "./entities/VMComponentEntity";
import { VMCustomEntity } from "./entities/VMCustomEntity";
import { VMEventEntity } from "./entities/VMEventEntity";
import { VMLabelEntity } from "./entities/VMLabelEntity";
import { VMNodeEntity } from "./entities/VMNodeEntity";
import { VMProgressEntity } from "./entities/VMProgressEntity";
import { VMSpriteEntity } from "./entities/VMSpriteEntity";


export class VMFatory{

    public static register(type: string,listenerClass){
        if(!type){
            throw new Error('VMFatory register [type] is null');
            return;
        }
        producers[type] = listenerClass;
    }

    public static getVMEntity(type: string){
        if(type in producers){
            return producers[type];
        }
        return null
    }

}

let producers = {
    'cc.Label': VMLabelEntity,
    'cc.RichText': VMLabelEntity,
    'cc.EditBox': VMLabelEntity,
    'cc.Node': VMNodeEntity,
    'cc.ProgressBar': VMProgressEntity,
    'cc.Slider': VMProgressEntity,    
    'cc.Sprite': VMSpriteEntity,
    'vm.Component': VMComponentEntity,
    'vm.ButtonClick': VMButtonClickEntity,
    'vm.Custom': VMCustomEntity,
    'vm.Event': VMEventEntity,
    'vm.Child': VMChildEntity,
    'vm.Children':VMChildrenEntity,
}

